#pragma once

#include "vertexbuffer.h"
#include "indexbuffer.h"
#include "rendertexture.h"
#include "file/file.h"

struct rendermaterial_t;

struct renderobject_t
{
	virtual void setupbuffers(){}
	virtual void onrender(){}
};

struct submesh_t
{
	submesh_t(){}
	void init(uint32 num_vertices, uint32 num_indices, rendermaterial_t* m);
	void set();
	void draw();

	vertexbuffer_t				vertexbuffer;
	indexbuffer_t				indexbuffer;
	rendermaterial_t*			material;
	fixedvector<rendertexture_t*,4> textures;
#ifdef LEO_DESIGNER
	void save(file_t& f);
#endif
	void load(file_t& f);
};

struct rendermesh_t
{
	void draw()
	{
		for (uint32 n=0; n<submesh.size(); ++n)
		{
			submesh[n].set();
			submesh[n].draw();
		}
	}
	vector<submesh_t> submesh;

#ifdef LEO_DESIGNER
	void save(file_t& f);
#endif
	void load(file_t& f);
};